package com.csii.pos.cashdaily.service.Impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.csii.pos.caacctewinfo.mapper.CaAcctEwInfoMapper;
import com.csii.pos.cashdaily.CashBulletin;
import com.csii.pos.cashdaily.CashBulletinVo;
import com.csii.pos.cashdaily.mapper.CashBulletinMapper;
import com.csii.pos.cashdaily.service.CashBulletinService;
import com.csii.pos.query.CashDaily;
import com.csii.pos.query.mapper.CashDailyMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;


@Service
public class CashBulletinServiceImpl extends ServiceImpl<CashBulletinMapper, CashDaily> implements CashBulletinService {
    @Resource
    private CashBulletinMapper cashBulletinMapper;

    @Override
    public List<CashBulletinVo> queryCashDaily(CashBulletin cashBulletin) {
        List<CashBulletin> iPage = cashBulletinMapper.selectByPrimaryKey(cashBulletin);
        List<CashBulletinVo> change = change(iPage);
        return change;
    }

    /**
     * @description: 查找那天到期方法
     * @param:
     * @return:
     * @author liuzhonghua
     * @date:  2021.7.20
     */
    private List<CashBulletinVo> change(List<CashBulletin> list){
        //新建转化后的List
        List<CashBulletinVo> cashBulletinVos = new ArrayList<>();
        for (CashBulletin c:list) {
            CashBulletinVo cashBulletin = new CashBulletinVo();
            cashBulletin.setCshRtpDt(c.getCshRtpDt());
            cashBulletin.setCshItemCd(c.getCshItemCd());
            cashBulletin.setCshCurBlc(c.getCshCurBlc());
            //判断那一天的到期，并存入新的List<CashBulletinVo>中
            if (c.getCshBlcNd()==0){
                //当日余额不为0且次日为0则是次日到期
                if (c.getCshCurBlc()!=0) {
                    cashBulletin.setCshBlcNd("到期");
                    cashBulletinVos.add(cashBulletin);
                }
            }else if (c.getCshBlc2d()==0){
                cashBulletin.setCshBlc2d("到期");
                cashBulletinVos.add(cashBulletin);
            }else if (c.getCshBlc3d()==0){
                cashBulletin.setCshBlc3d("到期");
                cashBulletinVos.add(cashBulletin);
            }else if (c.getCshBlc4d()==0){
                cashBulletin.setCshBlc4d("到期");
                cashBulletinVos.add(cashBulletin);
            }else if (c.getCshBlc5d()==0){
                cashBulletin.setCshBlc5d("到期");
                cashBulletinVos.add(cashBulletin);
            }else if (c.getCshBlc6d()==0){
                cashBulletin.setCshBlc6d("到期");
                cashBulletinVos.add(cashBulletin);
            }else if (c.getCshBlc7d()==0){
                cashBulletin.setCshBlc7d("到期");
                cashBulletinVos.add(cashBulletin);
            }
        }

        return cashBulletinVos;
    }



}
